package com.community.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.community.dao.IBaseDao;
import com.community.entity.ArticleCollection;
import com.community.service.IArticleCollectionService;

@Service
public class ArticleCollectionServiceImpl implements IArticleCollectionService{

	@Autowired
	private IBaseDao<ArticleCollection> acdao;
	
	@Override
	public void addArticleCollection(ArticleCollection a) {
		// TODO Auto-generated method stub
		acdao.save(a);
	}

	@Override
	public ArticleCollection getArticleCollectionByUseridAndArticleid(Long userid, Long articleid) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<>();
		params.put("1", userid);
		 params.put("2", articleid);
		return acdao.get("from ArticleCollection where userid = ?1 and articleid = ?2", params);
	}

	@Override
	public List<ArticleCollection> getArticleCollectionListByUserid(Long userid) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<>();
		params.put("1", userid);
		return acdao.find("from ArticleCollection where userid = ?1", params);
	}

	@Override
	public void deleteCollection(ArticleCollection a) {
		// TODO Auto-generated method stub
		acdao.delete(a);
	}

	@Override
	public ArticleCollection getArticleCollectionById(Long id) {
		// TODO Auto-generated method stub
		return acdao.get(ArticleCollection.class, id);
	}

}
